package com.ruoyi.system.mapper;

import com.ruoyi.system.domain.Area;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AreaMapper {
    @Select("select * from area where cm_id = IF(#{cm_id}='',cm_id,#{cm_id})")
    List<Area> findByCm_id(String cm_id);

    @Delete("delete from area where id = #{id} AND state = 0")
    boolean delete(String id);

    @Insert("INSERT INTO area(id, cm_id, x, y, width, height, name, time_span, state) VALUES " +
            "(#{id}, #{cm_id}, #{x}, #{y}, #{width}, #{height}, #{name},#{time_span}, #{state});")
    boolean add(Area area);

    @Update("update area set x = #{x}, y = #{y}, width = #{width}, height = #{height}, name = #{name}, time_span = #{time_span}, state = #{state} where id = #{id};")
    boolean update(Area area);
}
